/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using System.Collections.Generic;
using NetProtocol.POD;
using NetProtocol.Enum;
using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;
using IQIGame.Onigao.Framework;
using Cysharp.Threading.Tasks;
using System;
using static IQIGame.Onigao.Game.MessageWrapper;

namespace NetProtocol.Client {
	/// <summary>
	/// 任务模块
	/// module : quest
	/// </summary>
	public interface CNetQuest : INetClientModule {
		
		public ISession GetSession();
	
		Dictionary<int, INetClientModule.Package2MessageWrapper> INetClientModule.GetModuleFunction()
        {
            MessageFunction acceptQuestResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<AcceptQuestResultData>)wrapper;
                SC_acceptQuestResult(session, ref _wrapper.message);
                MessageWrapperPool<AcceptQuestResultData>.Put(_wrapper);
            };
            MessageFunction commitQuestResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<CommitQuestResultData>)wrapper;
                SC_commitQuestResult(session, ref _wrapper.message);
                MessageWrapperPool<CommitQuestResultData>.Put(_wrapper);
            };
            MessageFunction giveUpQuestResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<GiveUpQuestResultData>)wrapper;
                SC_giveUpQuestResult(session, ref _wrapper.message);
                MessageWrapperPool<GiveUpQuestResultData>.Put(_wrapper);
            };
            MessageFunction getPhaseRewardResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<GetPhaseRewardResultData>)wrapper;
                SC_getPhaseRewardResult(session, ref _wrapper.message);
                MessageWrapperPool<GetPhaseRewardResultData>.Put(_wrapper);
            };
            MessageFunction setTrackQuestResult_Delegate = (session, wrapper) =>
            {
            	var _wrapper = (MessageWrapper<SetTrackQuestResultData>)wrapper;
                SC_setTrackQuestResult(session, ref _wrapper.message);
                MessageWrapperPool<SetTrackQuestResultData>.Put(_wrapper);
            };
            MessageFunction notifyAcceptQuest_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyAcceptQuestData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyAcceptQuest, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyAcceptQuest(session, _wrapper.message.quests);
                MessageWrapperPool<NotifyAcceptQuestData>.Put(_wrapper);
            };
            MessageFunction notifyUpdateQuest_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyUpdateQuestData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyUpdateQuest, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyUpdateQuest(session, _wrapper.message.questPOD);
                MessageWrapperPool<NotifyUpdateQuestData>.Put(_wrapper);
            };
            MessageFunction notifyRemoveQuest_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyRemoveQuestData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyRemoveQuest, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyRemoveQuest(session, _wrapper.message.cids);
                MessageWrapperPool<NotifyRemoveQuestData>.Put(_wrapper);
            };
            MessageFunction notifyCommitQuest_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyCommitQuestData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyCommitQuest, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyCommitQuest(session, _wrapper.message.cids, _wrapper.message.awards, _wrapper.message.op);
                MessageWrapperPool<NotifyCommitQuestData>.Put(_wrapper);
            };
            MessageFunction notifyCommittedQuestList_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyCommittedQuestListData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyCommittedQuestList, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyCommittedQuestList(session, _wrapper.message.cids, _wrapper.message.remove);
                MessageWrapperPool<NotifyCommittedQuestListData>.Put(_wrapper);
            };
            MessageFunction notifyFailQuestList_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyFailQuestListData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyFailQuestList, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyFailQuestList(session, _wrapper.message.cids, _wrapper.message.remove);
                MessageWrapperPool<NotifyFailQuestListData>.Put(_wrapper);
            };
            MessageFunction notifyTrackQuest_Delegate = (session, wrapper) =>
            {
            var _wrapper = (MessageWrapper<NotifyTrackQuestData>)wrapper; 
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_notifyTrackQuest, "Recv->" + _wrapper.message.ToString());
#endif
                SC_notifyTrackQuest(session, _wrapper.message.cid);
                MessageWrapperPool<NotifyTrackQuestData>.Put(_wrapper);
            };
        
            Dictionary<int, INetClientModule.Package2MessageWrapper> retDic = new()
            {
                {NetMessageId.quest_acceptQuestResult, (session, package) => {
                	var result = MessageWrapperPool<AcceptQuestResultData>.Get();
                	result.Init(session, acceptQuestResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_commitQuestResult, (session, package) => {
                	var result = MessageWrapperPool<CommitQuestResultData>.Get();
                	result.Init(session, commitQuestResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_giveUpQuestResult, (session, package) => {
                	var result = MessageWrapperPool<GiveUpQuestResultData>.Get();
                	result.Init(session, giveUpQuestResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_getPhaseRewardResult, (session, package) => {
                	var result = MessageWrapperPool<GetPhaseRewardResultData>.Get();
                	result.Init(session, getPhaseRewardResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_setTrackQuestResult, (session, package) => {
                	var result = MessageWrapperPool<SetTrackQuestResultData>.Get();
                	result.Init(session, setTrackQuestResult_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyAcceptQuest, (session, package) => {
                	var result = MessageWrapperPool<NotifyAcceptQuestData>.Get();
                	result.Init(session, notifyAcceptQuest_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyUpdateQuest, (session, package) => {
                	var result = MessageWrapperPool<NotifyUpdateQuestData>.Get();
                	result.Init(session, notifyUpdateQuest_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyRemoveQuest, (session, package) => {
                	var result = MessageWrapperPool<NotifyRemoveQuestData>.Get();
                	result.Init(session, notifyRemoveQuest_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyCommitQuest, (session, package) => {
                	var result = MessageWrapperPool<NotifyCommitQuestData>.Get();
                	result.Init(session, notifyCommitQuest_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyCommittedQuestList, (session, package) => {
                	var result = MessageWrapperPool<NotifyCommittedQuestListData>.Get();
                	result.Init(session, notifyCommittedQuestList_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyFailQuestList, (session, package) => {
                	var result = MessageWrapperPool<NotifyFailQuestListData>.Get();
                	result.Init(session, notifyFailQuestList_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
                {NetMessageId.quest_notifyTrackQuest, (session, package) => {
                	var result = MessageWrapperPool<NotifyTrackQuestData>.Get();
                	result.Init(session, notifyTrackQuest_Delegate);
                	result.FromPackage(package);
                	return result;
                }},
            };
            return retDic;
        }
#region Client-side Interface
		/// <summary>
        /// Result只弹tips，不更新数据；notify中更新数据
        /// </summary>
		public void SC_acceptQuestResult(ISession session, ref AcceptQuestResultData message) 
		{
            _SC_acceptQuestResult(session, ref message);
		}
		
		public void _SC_acceptQuestResult(ISession session, ref AcceptQuestResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_acceptQuestResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.quest_acceptQuestResult, message.code);
			MsgAsyncAwaiter<AcceptQuestResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// 
        /// </summary>
		public void SC_commitQuestResult(ISession session, ref CommitQuestResultData message) 
		{
            _SC_commitQuestResult(session, ref message);
		}
		
		public void _SC_commitQuestResult(ISession session, ref CommitQuestResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_commitQuestResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.quest_commitQuestResult, message.code);
			MsgAsyncAwaiter<CommitQuestResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// 
        /// </summary>
		public void SC_giveUpQuestResult(ISession session, ref GiveUpQuestResultData message) 
		{
            _SC_giveUpQuestResult(session, ref message);
		}
		
		public void _SC_giveUpQuestResult(ISession session, ref GiveUpQuestResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_giveUpQuestResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.quest_giveUpQuestResult, message.code);
			MsgAsyncAwaiter<GiveUpQuestResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        ///  成功时需更新任务数据
        /// </summary>
		public void SC_getPhaseRewardResult(ISession session, ref GetPhaseRewardResultData message) 
		{
            _SC_getPhaseRewardResult(session, ref message);
		}
		
		public void _SC_getPhaseRewardResult(ISession session, ref GetPhaseRewardResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_getPhaseRewardResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.quest_getPhaseRewardResult, message.code);
			MsgAsyncAwaiter<GetPhaseRewardResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// Result只弹tips
        /// </summary>
		public void SC_setTrackQuestResult(ISession session, ref SetTrackQuestResultData message) 
		{
            _SC_setTrackQuestResult(session, ref message);
		}
		
		public void _SC_setTrackQuestResult(ISession session, ref SetTrackQuestResultData message)
		{
#if ENABLE_NET_LOG || UNITY_EDITOR
            NetProtocolHelper.ClientLog(NetMessageId.quest_setTrackQuestResult, "Recv->" + message.ToString());
#endif
			NetProtocolHelper.endCallRequest?.Invoke(NetMessageId.quest_setTrackQuestResult, message.code);
			MsgAsyncAwaiter<SetTrackQuestResultData>.Instance.CompleteMsgAwait(ref message);
		}
		
		/// <summary>
        /// 通知接取任务 -- 插入到进行中列表，可能由服务器触发
        /// </summary>
		protected void SC_notifyAcceptQuest(ISession session, List<QuestPOD> quests);
		/// <summary>
        /// 更新任务信息
        /// </summary>
		protected void SC_notifyUpdateQuest(ISession session, QuestPOD questPOD);
		/// <summary>
        /// 移除任务 -- 从进行列表中删除，可能由服务器触发
        /// </summary>
		protected void SC_notifyRemoveQuest(ISession session, List<int> cids);
		/// <summary>
        /// 通知提交任务结果 -- 仅做展示
        /// </summary>
		protected void SC_notifyCommitQuest(ISession session, List<int> cids, List<ItemShowPOD> awards, QuestCommitOp op);
		/// <summary>
        /// 更新已提交的任务列表,remove: true表示从commitList中移除，否则表示添加
        /// </summary>
		protected void SC_notifyCommittedQuestList(ISession session, List<int> cids, bool remove);
		/// <summary>
        /// 更新已失败的任务列表,remove: true表示从failedList中移除，否则表示添加
        /// </summary>
		protected void SC_notifyFailQuestList(ISession session, List<int> cids, bool remove);
		/// <summary>
        /// 通知追踪任务信息
        /// </summary>
		protected void SC_notifyTrackQuest(ISession session, int cid);
#endregion
#region Server-side Interface
		/// <summary>
        /// 接取任务
        /// </summary>
    	public UniTask<AcceptQuestResultData> CS_acceptQuest(int cid)
        {
            return _CS_acceptQuest(cid);
        }
        
        public UniTask<AcceptQuestResultData> _CS_acceptQuest(int cid)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(AcceptQuestResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.quest_acceptQuest, "Send->"+"Quest.CS_acceptQuest { "
				+ "cid="
				+ cid
				+" }");
#endif
        	UniTask<AcceptQuestResultData> task = MsgAsyncAwaiter<AcceptQuestResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_acceptQuest(cid));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.quest_acceptQuestResult);
			return task;
        }
		
		public static SendPackage Pack_for_acceptQuest(int cid) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.quest_acceptQuest;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_int(cid);
			return si_p;
		}
		/// <summary>
        /// 提交任务--可批量
        /// </summary>
    	public UniTask<CommitQuestResultData> CS_commitQuest(List<int> cids, bool batch)
        {
            return _CS_commitQuest(cids, batch);
        }
        
        public UniTask<CommitQuestResultData> _CS_commitQuest(List<int> cids, bool batch)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(CommitQuestResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.quest_commitQuest, "Send->"+"Quest.CS_commitQuest { "
				+ "cids="
				+ cids.ToString<int>()
				+ ", batch="
				+ batch
				+" }");
#endif
        	UniTask<CommitQuestResultData> task = MsgAsyncAwaiter<CommitQuestResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_commitQuest(cids, batch));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.quest_commitQuestResult);
			return task;
        }
		
		public static SendPackage Pack_for_commitQuest(List<int> cids, bool batch) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.quest_commitQuest;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_list_int(cids);	
			_out.Write_boolean(batch);
			return si_p;
		}
		/// <summary>
        /// 放弃任务
        /// </summary>
    	public UniTask<GiveUpQuestResultData> CS_giveUpQuest(int cid)
        {
            return _CS_giveUpQuest(cid);
        }
        
        public UniTask<GiveUpQuestResultData> _CS_giveUpQuest(int cid)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(GiveUpQuestResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.quest_giveUpQuest, "Send->"+"Quest.CS_giveUpQuest { "
				+ "cid="
				+ cid
				+" }");
#endif
        	UniTask<GiveUpQuestResultData> task = MsgAsyncAwaiter<GiveUpQuestResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_giveUpQuest(cid));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.quest_giveUpQuestResult);
			return task;
        }
		
		public static SendPackage Pack_for_giveUpQuest(int cid) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.quest_giveUpQuest;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_int(cid);
			return si_p;
		}
		/// <summary>
        /// 领取阶段奖励
        /// </summary>
    	public UniTask<GetPhaseRewardResultData> CS_getPhaseReward(int cid, int phase)
        {
            return _CS_getPhaseReward(cid, phase);
        }
        
        public UniTask<GetPhaseRewardResultData> _CS_getPhaseReward(int cid, int phase)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(GetPhaseRewardResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.quest_getPhaseReward, "Send->"+"Quest.CS_getPhaseReward { "
				+ "cid="
				+ cid
				+ ", phase="
				+ phase
				+" }");
#endif
        	UniTask<GetPhaseRewardResultData> task = MsgAsyncAwaiter<GetPhaseRewardResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_getPhaseReward(cid, phase));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.quest_getPhaseRewardResult);
			return task;
        }
		
		public static SendPackage Pack_for_getPhaseReward(int cid, int phase) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.quest_getPhaseReward;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_int(cid);
			_out.Write_int(phase);
			return si_p;
		}
		/// <summary>
        /// 设置追踪任务，cid为0表示取消
        /// </summary>
    	public UniTask<SetTrackQuestResultData> CS_setTrackQuest(int cid)
        {
            return _CS_setTrackQuest(cid);
        }
        
        public UniTask<SetTrackQuestResultData> _CS_setTrackQuest(int cid)
        {
        	ISession session = GetSession();
        	if(session == null) return UniTask.FromResult(default(SetTrackQuestResultData));
#if ENABLE_NET_LOG || UNITY_EDITOR
			NetProtocolHelper.ClientLog(NetMessageId.quest_setTrackQuest, "Send->"+"Quest.CS_setTrackQuest { "
				+ "cid="
				+ cid
				+" }");
#endif
        	UniTask<SetTrackQuestResultData> task = MsgAsyncAwaiter<SetTrackQuestResultData>.Instance.AddMsgAwait();
        	session.SendPack(Pack_for_setTrackQuest(cid));
        	NetProtocolHelper.beginCallRequest?.Invoke(NetMessageId.quest_setTrackQuestResult);
			return task;
        }
		
		public static SendPackage Pack_for_setTrackQuest(int cid) 
		{
			SendPackage si_p = NetProtocolHelper.GetSendPackage();
			si_p.Header.Messagid = NetMessageId.quest_setTrackQuest;
			si_p.StartWrite();
			SOutputStream _out = si_p.OutputStream;
			_out.Write_int(cid);
			return si_p;
		}
#endregion
#region Messages
        public struct AcceptQuestResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_acceptQuestResult;}
            
            public override string ToString()
            {
                return "Quest.acceptQuestResult"+ ", code="+ code;
            }
        }
        public struct CommitQuestResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_commitQuestResult;}
            
            public override string ToString()
            {
                return "Quest.commitQuestResult"+ ", code="+ code;
            }
        }
        public struct GiveUpQuestResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_giveUpQuestResult;}
            
            public override string ToString()
            {
                return "Quest.giveUpQuestResult"+ ", code="+ code;
            }
        }
        public struct GetPhaseRewardResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
	        public List<ItemShowPOD> awards;
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
                awards = _in.HasRemaining() ? _in.Read_list_pod<ItemShowPOD>(ItemShowPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_getPhaseRewardResult;}
            
            public override string ToString()
            {
                return "Quest.getPhaseRewardResult"+ ", code="+ code+ ", awards="+ awards.ToString<ItemShowPOD>();
            }
        }
        public struct SetTrackQuestResultData : IReceiveMessage {
        	private int? _code;
        	public int code {get{return _code == null ? -1 : (int)_code;}private set{_code = value;}}
            public bool IsFail => _code != null && _code != 0;
            public bool IsSuccess =>_code != null && _code == 0;
            public bool IsCanceled => _code == null;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                code = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_setTrackQuestResult;}
            
            public override string ToString()
            {
                return "Quest.setTrackQuestResult"+ ", code="+ code;
            }
        }
        public struct NotifyAcceptQuestData : IReceiveMessage {
	        public List<QuestPOD> quests;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                quests = _in.HasRemaining() ? _in.Read_list_pod<QuestPOD>(QuestPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyAcceptQuest;}
            
            public override string ToString()
            {
                return "Quest.notifyAcceptQuest"+ ", quests="+ quests.ToString<QuestPOD>();
            }
        }
        public struct NotifyUpdateQuestData : IReceiveMessage {
	        public QuestPOD questPOD;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                questPOD = _in.HasRemaining() ? _in.Read_pod<QuestPOD>(QuestPOD.DynamicFactory) : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyUpdateQuest;}
            
            public override string ToString()
            {
                return "Quest.notifyUpdateQuest"+ ", questPOD="+ questPOD;
            }
        }
        public struct NotifyRemoveQuestData : IReceiveMessage {
	        public List<int> cids;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                cids = _in.HasRemaining() ? _in.Read_list_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyRemoveQuest;}
            
            public override string ToString()
            {
                return "Quest.notifyRemoveQuest"+ ", cids="+ cids.ToString<int>();
            }
        }
        public struct NotifyCommitQuestData : IReceiveMessage {
	        public List<int> cids;
	        public List<ItemShowPOD> awards;
	        public QuestCommitOp op;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                cids = _in.HasRemaining() ? _in.Read_list_int() : default;
                awards = _in.HasRemaining() ? _in.Read_list_pod<ItemShowPOD>(ItemShowPOD.DynamicFactory) : default;
                op = _in.HasRemaining() ? (QuestCommitOp)_in.Read_byte() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyCommitQuest;}
            
            public override string ToString()
            {
                return "Quest.notifyCommitQuest"+ ", cids="+ cids.ToString<int>()+ ", awards="+ awards.ToString<ItemShowPOD>()+ ", op="+ op;
            }
        }
        public struct NotifyCommittedQuestListData : IReceiveMessage {
	        public List<int> cids;
	        public bool remove;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                cids = _in.HasRemaining() ? _in.Read_list_int() : default;
                remove = _in.HasRemaining() ? _in.Read_boolean() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyCommittedQuestList;}
            
            public override string ToString()
            {
                return "Quest.notifyCommittedQuestList"+ ", cids="+ cids.ToString<int>()+ ", remove="+ remove;
            }
        }
        public struct NotifyFailQuestListData : IReceiveMessage {
	        public List<int> cids;
	        public bool remove;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                cids = _in.HasRemaining() ? _in.Read_list_int() : default;
                remove = _in.HasRemaining() ? _in.Read_boolean() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyFailQuestList;}
            
            public override string ToString()
            {
                return "Quest.notifyFailQuestList"+ ", cids="+ cids.ToString<int>()+ ", remove="+ remove;
            }
        }
        public struct NotifyTrackQuestData : IReceiveMessage {
	        public int cid;
            public void FromPackage(ReceivePackage _package)
            {
                SInputStream _in = _package.InputStream;
                cid = _in.HasRemaining() ? _in.Read_int() : default;
            }
            
            public int GetMessageId() {return NetMessageId.quest_notifyTrackQuest;}
            
            public override string ToString()
            {
                return "Quest.notifyTrackQuest"+ ", cid="+ cid;
            }
        }
    }
#endregion
}